import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { BaseinfoChathistoryApi } from '#/api/csyt/baseinfochathistory';

import { DICT_TYPE, getDictOptions, getRangePickerDefaultProps } from '#/utils';

/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'chatId',
      label: '会话ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入回话ID',
        readOnly:true,
        show: () => false,
      },
    },
    {
      fieldName: 'chatNo',
      label: '会话编码',
      component: 'Input',
      componentProps: {
        placeholder: '请输入会话ID',
        readOnly:true
      },
    },

    {
      fieldName: 'chatName',
      label: '会话标题',
      component: 'Input',
      rules: 'required',
      componentProps: {
        placeholder: '请输入回话标题',
      },
    },
    {
      fieldName: 'chatDescription',
      label: '会话描述',
      component: 'Textarea',
      componentProps: {
        rows: 4,
        placeholder: '请输入会话描述',
      },
      // component: 'RichTextarea',
    },
    {
      fieldName: 'tempFile',
      label: '模板文件',
      component: 'FileUpload',
    },
    // {
    //   fieldName: 'demaToProd',
    //   label: '发起方',
    //   component: 'RadioGroup',
    //   componentProps: {
    //     options: [],
    //     buttonStyle: 'solid',
    //     optionType: 'button',
    //   },
    // },
    {
      fieldName: 'messageType',
      label: '紧急程度',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.CSYT_MESSAGE_TYPE, 'number'),
        placeholder: '请选择紧急程度',
      },
    },
    {
      fieldName: 'messageBody',
      label: '消息内筒',
      component: 'Input',
      componentProps: {
        placeholder: '请输入消息内筒',
      },
    },
    {
      fieldName: 'sendTime',
      label: '发送时间',
      rules: 'required',
      component: 'DatePicker',
      componentProps: {
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
      },
    },
    // {
    //   fieldName: 'flag',
    //   label: '1新增2更新3删除',
    //   rules: 'required',
    //   component: 'RadioGroup',
    //   componentProps: {
    //     options: getDictOptions(DICT_TYPE.CSYT_MESSAGE_TYPE, 'number'),
    //     buttonStyle: 'solid',
    //     optionType: 'button',
    //   },
    // },
  ];
}
export function useFormSchemaCall(): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
      component: 'Input',
      dependencies: {
        triggerFields: [''],
        show: () => false,
      },
    },
    {
      fieldName: 'chatId',
      label: '会话ID',
      component: 'Input',
      componentProps: {
        placeholder: '请输入回话ID',
        readOnly:true

      },
    },
    {
      fieldName: 'chatNo',
      label: '会话编码',
      component: 'Input',
      componentProps: {
        placeholder: '请输入会话ID',
        readOnly:true
      },
    },
    {
      fieldName: 'chatName',
      label: '会话标题',
      component: 'Input',
      rules: 'required',
      componentProps: {
        placeholder: '请输入会话标题',
        readOnly:true
      },
    },
    {
      fieldName: 'chatDescription',
      label: '会话描述',
      component: 'Textarea',
      componentProps: {
        rows: 3,
        placeholder: '请输入会话描述',
      },
    },
    {
      fieldName: 'tempFile',
      label: '模板文件',
      component: 'FileUpload',
    },
    {
      fieldName: 'messageType',
      label: '紧急程度',
      rules: 'required',
      component: 'Select',
      componentProps: {
        options: getDictOptions(DICT_TYPE.CSYT_MESSAGE_TYPE, 'number'),
        placeholder: '请选择紧急程度',
      },
    },
    {
      fieldName: 'replyDescription',
      label: '标题回复',
      rules: 'required',
      component: 'Textarea',
      componentProps: {
        rows: 3,
        placeholder: '请输入会话描述',
      },
    },
    {
      fieldName: 'replyFile',
      label: '回复附件',
      component: 'FileUpload',
    },
  ];
}
/** 列表的搜索表单 */
export function useGridFormSchema(): VbenFormSchema[] {
  return [
    {
      fieldName: 'chatName',
      label: '会话标题',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入会话标题',
      },
    },
    {
      fieldName: 'chatDescription',
      label: '会话描述',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入会话描述',
      },
    },
    // {
    //   fieldName: 'tempFile',
    //   label: '模板文件',
    //   component: 'FileUpload',
    // },
    {
      fieldName: 'demaToProd',
      label: '发起方',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: [],
        placeholder: '请选择发起方',
      },
    },
    {
      fieldName: 'messageType',
      label: '紧急程度',
      component: 'Select',
      componentProps: {
        allowClear: true,
        options: getDictOptions(DICT_TYPE.CSYT_MESSAGE_TYPE, 'number'),
        placeholder: '请选择紧急程度',
      },
    },
    {
      fieldName: 'messageBody',
      label: '消息内筒',
      component: 'Input',
      componentProps: {
        allowClear: true,
        placeholder: '请输入消息内筒',
      },
    },
    {
      fieldName: 'sendTime',
      label: '发送时间',
      component: 'RangePicker',
      componentProps: {
        ...getRangePickerDefaultProps(),
        allowClear: true,
      },
    },
    // {
    //   fieldName: 'flag',
    //   label: '操作',
    //   component: 'Select',
    //   componentProps: {
    //     allowClear: true,
    //     options: getDictOptions(DICT_TYPE.CSYT_MESSAGE_TYPE, 'number'),
    //     placeholder: '请选择操作',
    //   },
    // },
  ];
}

/** 列表的字段 */
export function useGridColumns(): VxeTableGridOptions<BaseinfoChathistoryApi.BaseinfoChathistory>['columns'] {
  return [
    { type: 'checkbox', width: 40 },
    {
      field: 'id',
      title: '序号',
      minWidth: 120,
    },
    {
      field: 'chatId',
      title: '会话ID',
      minWidth: 120,
    },
    {
      field: 'chatName',
      title: '会话标题',
      minWidth: 120,
    },
    // {
    //   field: 'chatDescription',
    //   title: '会话描述',
    //   minWidth: 120,
    // },
    // {
    //   field: 'tempFile',
    //   title: '模板文件',
    //   minWidth: 120,
    // },
    {
      field: 'messageType',
      title: '紧急程度',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.CSYT_MESSAGE_TYPE},
      },

    },
    {
      field: 'status',
      title: '会话交流状态',
      minWidth: 120,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.CSYT_CHAT_STATUS },
      },
    },
    {
      field: 'demaToProd',
      title: '发起方',
      minWidth: 120,
    },
    {
      field: 'sendTime',
      title: '发送时间',
      minWidth: 120,
      formatter: 'formatDateTime',
    },
    {
      field: 'replyUser',
      title: '回复人',
      minWidth: 120,
    },
    {
      field: 'replyTime',
      title: '回复时间',
      minWidth: 120,
    },
    // {
    //   field: 'messageBody',
    //   title: '消息内筒',
    //   minWidth: 120,
    // },


    {
      title: '操作',
      width: 200,
      fixed: 'right',
      slots: { default: 'actions' },
    },
  ];
}
